package com.aaa.order.controller;



import com.aaa.order.properties.OrderProperties;
import com.aaa.order.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

////自动刷新属性值
//@RefreshScope
@RestController
@RequestMapping("/api/order")
public class OrderController {

    @Resource
    OrderService orderService;

    @Resource
    OrderProperties orderProperties;


    //使用注解来发现配置
//    @Value("${order.timeout}")
//    String orderTimeout;
//    @Value("${order.auto-confirm}")
//    String orderAutoConfirm;


//    @GetMapping(value="/config")
//    public String config(){
//        return "order.timeout=" + orderTimeout+",order.auto-confirm=" + orderAutoConfirm;
//    }

    @GetMapping(value="/config")
    public String config(){
        return "order.timeout=" + orderProperties.getTimeout()+",order.auto-confirm=" + orderProperties.getAutoConfirm();
    }

    @GetMapping(value = "/getProdUctById")
    //查询订单
    public String getProdUctById(@RequestParam("orderId") Long orderId) {
        return  orderService.getProdUctById(orderId);
    }

//    @GetMapping(value = "/getProdUctById")
//    //查询订单
//    public String getProdUctById(@RequestParam("orderId") Long orderId) {
//        return  orderService.getProdUctById(orderId);
//    }




//    @GetMapping(value = "/getShopFrom")
//    //查询服务
//    public String getShopFrom() {
//        return  orderService.getShopFrom();
//    }


}
